//
//  IMIAudioRecorder.h
//  MiHome
//
//  Created by 阎超 on 16/05/2017.
//  Copyright © 2017 小米移动软件. All rights reserved.
//

#import <Foundation/Foundation.h>
#import <AudioToolbox/AudioToolbox.h>
#import "IMIMediaFrameworkBase.h"

#define AUDIO_BUFFERS 3
#define DOCUMENTS_FOLDER [NSHomeDirectory() stringByAppendingPathComponent:@"Documents"]

@protocol IMIAudioRecordDelegate<NSObject>
-(void) onAudioDataReady:(void*)audioData
                  length:(unsigned int) length;
@end


//typedef struct {
//    //         AudioFileID                 audioFile;
//    AudioStreamBasicDescription dataFormat;
//    AudioQueueRef               queue;
//    AudioQueueBufferRef         buffers[AUDIO_BUFFERS];
//    UInt32                      bufferByteSize;
//    SInt64                      currentPacket;
//    BOOL                        recording;
//} IMIRecordState;

@interface IMIAudioRecorder : NSObject {
//    IMIRecordState recordState;
}
@property (nonatomic, assign) NSInteger smpRate;
@property (nonatomic, assign) float pcmGain;
@property (nonatomic,   weak) id<IMIAudioRecordDelegate> delegate;

//- (float) averagePower;
//- (float) peakPower;
//- (float) currentTime;
//- (void)  stopRecording;
//- (void)  pause;
//- (BOOL)  resume;
//- (BOOL)  startRecordingWithType:(int)type;

-(void) startUnitRecording;
-(void) stopUnitRecording;
-(void) setAudiodata:(NSData *)data;
-(NSMutableArray *) audiobuffer;
-(AudioUnit) audioUnit;
-(void) processAudio: (AudioBufferList *)bufferList numberFrames: (int) inNumberFrames ;
-(void) setPlaydata: (void *)buffer withSize: (int) size;


@end
